package com.wanmait.bootdemo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.bootdemo.mapper.QuestionTypeMapper;
import com.wanmait.bootdemo.pojo.QuestionType;
import com.wanmait.bootdemo.service.QuestionTypeService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class QuestionTypeServiceImpl implements QuestionTypeService {
    @Resource
    private QuestionTypeMapper questionTypeMapper;

    private Logger logger = LogManager.getLogger(QuestionTypeServiceImpl.class);
    @Override
    public List<QuestionType> findAll() {
        logger.info("findAll questionTypes...................");
        logger.debug("debug findAll questionTypes...............");

        return questionTypeMapper.selectList();
    }
    @Override
    public PageInfo<QuestionType> findAll(int pageNum) {
        //下面两个不会写死，应该从数据库的配置表中查询出来
        //每页显示条数
        int pageSize=5;
        //导航页码数量
        int navigatePages = 11;
        PageHelper.startPage(pageNum,pageSize);
        List<QuestionType> questionTypes = questionTypeMapper.selectList();
        PageInfo<QuestionType> pageInfo = new PageInfo<>(questionTypes,navigatePages);
        return pageInfo;
    }

    @Override
    public void insert(QuestionType object) {
        questionTypeMapper.insert(object);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public void update(QuestionType object) {

    }

    @Override
    public QuestionType findById(Integer id) {
        return null;
    }


}
